package com.wanhugou.payment.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

@Component
@Configuration
public class AliPayConfig {

    // 商户的私钥
	@Value("${APP_PRIVATE_KEY}")
	private String app_private_key;
	
	@Value("${ALI_GATEWAY}")
	private String ali_gateway;
	
	@Value("${APP_ID}")
	private String app_id;
    
	// 支付宝的公钥
	@Value("${ALI_PUBLIC_KEY}")
	private String ali_public_key;

    // 字符编码格式 目前支持 gbk 或 utf-8
	@Value("${CHARSET}")
	private String charset;
    
    // 签名方式
	@Value("${SIGN_TYPE}")
    private String sign_type;
	
	@Bean
    public AlipayClient getClient(){
    	AlipayClient alipayClient = new DefaultAlipayClient(
    			ali_gateway, app_id, app_private_key, "json", charset, ali_public_key, sign_type); //获得初始化的AlipayClient
    	return alipayClient;
    }

	public String getApp_private_key() {
		return app_private_key;
	}

	public void setApp_private_key(String app_private_key) {
		this.app_private_key = app_private_key;
	}

	public String getAli_gateway() {
		return ali_gateway;
	}

	public void setAli_gateway(String ali_gateway) {
		this.ali_gateway = ali_gateway;
	}

	public String getApp_id() {
		return app_id;
	}

	public void setApp_id(String app_id) {
		this.app_id = app_id;
	}

	public String getAli_public_key() {
		return ali_public_key;
	}

	public void setAli_public_key(String ali_public_key) {
		this.ali_public_key = ali_public_key;
	}

	public String getCharset() {
		return charset;
	}

	public void setCharset(String charset) {
		this.charset = charset;
	}

	public String getSign_type() {
		return sign_type;
	}

	public void setSign_type(String sign_type) {
		this.sign_type = sign_type;
	}
	
}
